package ControlLayer;
import java.util.ArrayList;
import ModelLayer.*;
/**
 * Controller class for the DVD collection
 * 
 * @author (kbh) 
 * @version (2005.03.31)
 * @revised version English (Ab)
 * (FEN): 2006.03.21: Some changes to the architecture in order to assure layering
 *                    and loose coupling
 */
public class DVDCtr
{


//     private DVD d;
    private DVDKontainer dk;

    /**
     * Constructor for objects of class DVDCtr
     */
    public DVDCtr()
    {
        dk = DVDKontainer.getInstance();    
    }

    public DVD findDVD(int id)
    {
       DVD fDVD = dk.findDVD(id);
       if (fDVD != null)
       {
    }
    return fDVD;
    }
    
   
    public void createDVD(String title, String releaseDate)
    {       
          dk.addDVD(title, releaseDate);
    }
    
    public void deleteDVD(int id)
    {
      dk.deleteDVD(id);
    }
    
//     public void deleteDVD(int id)
//     {
//     boolean deleted = false;
//     while(deleted == false){
//         if(dk.findDVD(id) != null) {
//                 dk.removeDVD(id);
//                 deleted = true;
//         }
//         }
//     }
    
    public void opretEksemplar(int id, String serienr, String anskaffelsesDato, String anskaffelsesPris)
    {
        //create a copy of the specified dvd and add it to the dvd
        DVD dvd = findDVD(id);
        if(dvd != null)
        {
        System.out.println("ID " + id + " er fundet");
        dvd.opretEksemplar(serienr, anskaffelsesDato, anskaffelsesPris);
        } else {
         System.out.println("DVD  med id-nummer: " + id + " er ikke fundet");
        }
    }
    
    public ArrayList<DVD> listAllDvds()
    {
          return dk.getAllDvds();
    }
    
    public void printDVDsToPrompt()
    {
     
      dk.printAllDVDToPrompt(); 
   
    }
    
}
